﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" 
  xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
  exclude-result-prefixes="msxsl"
>
  <!--Use the article at http://www.biglist.com/lists/xsl-list/archives/200012/msg00175.html as a reference. -->
    <xsl:output method="xml" indent="yes"/>

  <xsl:key name="next-headings" match="w:p[number(w:pPr/w:numPr/w:ilvl/@w:val) &gt; 0]"
          use="generate-id(preceding-sibling::*[self::h1 or self::h2 or
                                               self::h3 or self::h4 or
                                               self::h5][1])" />
</xsl:stylesheet>
